package cn.xmstore.util;

import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author： Aeolia
 * @Description： TODO 验证码工具类
 * @Date： 2021/9/1 18:42
 */
@Component("checkCodeUtil")
public class CheckCodeUtil {
    private Random RANDOM = new Random();
    private int BIT = 6;

    public String createCheckCode() {
        StringBuffer bufferCode = new StringBuffer();
        for (int i = 0; i < BIT; i++) {
            bufferCode.append(RANDOM.nextInt(10));
        }
        return bufferCode.toString();
    }

    public String createCheckCode(int bit) {
        BIT = bit;
        return createCheckCode();
    }

}
